const fs = require('fs').promises;
const path = require('path')

async function main() {
  const data = await fs.readFile(path.join(__dirname, 'public/baidusitemap.xml'), 'utf8')
  // console.log(data);
  const urls = data.match(/\<loc\>(.+)\<\/loc\>/g).map(item => item.replace(/<[^>]+>/g,'')).join('\n')
  // console.log(urls);
  fs.writeFile('./urls.txt', urls)
}

main()